# -*- coding: utf-8 -*-
# @Time    : 2025/1/22 下午14:29
# @Author  : lh
# @Email   : lhhlhh822@peatlmail.com
# @File    :
# @Software: PyCharm

from pages.base_page import BasePage
from selenium.webdriver.common.by import By


# 新建合同页面
class NewSchedulePage(BasePage):
    url = '/crm/index.php?m=contract&a=add'
    bh_locator = (By.ID, 'number')  # 编号
    time_locator = (By.ID, 'due_time')  # 时间
    sj_locator = (By.ID, 'business_name')  # 商机
    nb_dj_locator = (By.CSS_SELECTOR, '#data > tr > td:nth-child(1) > input[type=radio]:nth-child(1)')  # 添加商机
    nb_last_dj_locator = (By.CSS_SELECTOR, '#data > tr:nth-child(6) > td:nth-child(1) > input[type=radio]:nth-child(1)')
    dj_locator = (By.XPATH, '/html/body/div[7]/div[3]/div/button[1]')
    # 点击确定
    # 负责人
    fzr_locator = (By.NAME, 'owner_role_name')
    # 勾选负责人
    last_fzr_locator = (By.CSS_SELECTOR, '#d_content > tr:nth-child(2) > td:nth-child(1) > input[type=radio]')
    # 点击ok
    dj_fzr_locator = (By.CSS_SELECTOR,
                      'body > div:nth-child(13) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div '
                      '> button:nth-child(1)')
    price_locator = (By.ID, 'price')  # 金额
    start_time_locator = (By.ID, 'start_date')  # 生效时间
    end_time_locator = (By.ID, 'end_date')  # 到期时间
    terms_locator = (By.CSS_SELECTOR, 'body')  # 条件和扣款
    ms_locator = (By.CSS_SELECTOR, '#description')  # 描述
    bc_locator = (By.CSS_SELECTOR,
                  'body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > '
                  'input.btn.btn-primary')
    result_locator = (By.XPATH, '/html/body/div[5]/div[2]')
    # look_table_locator = (By.CSS_SELECTOR, '#form1 > table')
    # tr_locator = (By.TAG_NAME, 'tr')
    # td_locator = (By.TAG_NAME, 'td')
    # checkbox_id_locator = (By.TAG_NAME, 'input')
    # look_a_locator = (By.TAG_NAME, 'a')



    # 操作
    def input_bh(self, bh):
        self.find_element(self.bh_locator).clear()
        self.find_element(self.bh_locator).send_keys(bh)  # 清空编号，输入编号

    def input_time(self, time):
        self.find_element(self.time_locator).send_keys(time)  # 签约时间

    def click_sj(self):
        self.find_element(self.sj_locator).click()  # 商机

    def click_nb_tj(self):
        self.find_element(self.nb_dj_locator).click()  # 内部添加商机

    def click_nb_last_tj(self):
        self.find_element(self.nb_last_dj_locator).click()  # 内部添加商机

    def click_dj(self):
        self.find_element(self.dj_locator).click()  # 点击确定

    def input_fzr(self, fzr):
        self.find_element(self.fzr_locator).clear()
        self.find_element(self.fzr_locator).send_keys(fzr)  # 清除负责人，输入负责人

    def click_fzr(self):
        self.find_element(self.fzr_locator).clear()  # 清除负责人
        self.find_element(self.fzr_locator).click()
        self.find_element(self.last_fzr_locator).click()  #点击负责人

    def click_dj_fzr(self):
        self.find_element(self.dj_fzr_locator).click()  # 点击负责人ok

    def input_price(self, price):
        self.find_element(self.price_locator).send_keys(price)  # 合同金额

    def input_start_time(self, stime):
        self.find_element(self.start_time_locator).send_keys(stime)  # 生效时间

    def input_end_time(self, etime):
        self.find_element(self.end_time_locator).send_keys(etime)  # 到期时间

    def input_terms(self, terms):
        self.find_element(self.terms_locator).send_keys(terms)  # 条件和扣款

    def input_ms(self, ms):
        self.find_element(self.ms_locator).send_keys(ms)  # 描述

    def click_bc(self):
        self.find_element(self.bc_locator).click()  # 保存
#返回增删改查后的提示信息
    def get_result_tips(self):
        return self.find_element(self.result_locator).text